package fluxx.draft;

import java.awt.Color;

public abstract class Goal extends Card {
	
	public Goal(String name, String description) {
		super(name, description);
	}

	@Override
	public Color getColor() {
		return Color.MAGENTA;
	}
	
	public boolean hasWinner(GameState game) {
		try {
			getWinner(game);
			return true;
		} catch (RuntimeException exc) { // TODO Whaat
			return false;
		}
	}
	
	public abstract Player getWinner(GameState game);
	
	@Override
	public void bePlayed(GameState game, Player player) throws GameOverException {
		if (game.goal != null)
			game.discard(game.goal);
		game.goal = this;
		game.checkGoalSatisfied();
	}
}
